<template>
	<view>
	</view>
</template>

<script setup>
/*
获取评论
*/
function get_comment(aid){
	return new Promise((resolve,reject)=>{
		uni.request({
			url:"https://ku.qingnian8.com/dataApi/news/comment.php",
			success:res=>{
				resolve(res)
			},
			fail:res=> {
				reject(res)
			}
		})
	})
}

/*
获取新闻列表
*/
function get_newslist(cid){
	return new Promise((resolve,reject)=>{
		uni.request({
			url:"https://ku.qingnian8.com/dataApi/news/newslist.php",
			data:{
			  cid:cid
			},
			success:res=>{
				resolve(res)
			},
			fail:res=> {
				reject(res)
			}
		})
	})
}

/*
获取导航列表
*/
function get_navlist(){
	return new Promise((resolve,reject)=>{
		uni.request({
			url:"https://ku.qingnian8.com/dataApi/news/navlist.php",
			success:res=>{
				resolve(res)
			},
			fail:res=> {
				reject(res)
			}
		})
	})
}


/*
async await方式  （异步代码，同步执行）
*/
async function init(){
	let res1 = await get_navlist();
	let cid = res1.data[0].id
	let res2 = await get_newslist(cid)
	let aid = res2.data[0].id;
	let res3 = await get_comment(aid)
	console.log(res3);
}
init()
</script>

<style lang="scss" scoped>

</style>
